<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.ViewData.NewsNewViewData>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Admin: Create <%= System.Configuration.ConfigurationManager.AppSettings["SiteName2"] %> News</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript" src='<%= Url.Content("~/Scripts/ckeditor/ckeditor.js") %>'></script>
    <script type="text/javascript" src='<%= Url.Content("~/Scripts/ckeditor/adapders/jquery.js") %>'></script>
    
    <script type="text/javascript" language="javascript">
        var editor = CKEDITOR.replace('Description');
    </script>
    
    <script type="text/javascript" language="javascript">

        $(document).ready(function() {
            $('#submit').click(function() {
            var content = editor.getContent(); // get the content
                $('#Description').val(content); // put it in the textarea
            });

            $('#submit_view').click(function() {
            var content = editor.getContent(); // get the content
                $('#Description').val(content); // put it in the textarea
            });
        
            $("#NewsForm").validate({
                rules:
                {
                    Title:
                    {
                        required: true
                    },
                    SubTitle:
                    {
                        required: true
                    },
                    Description:
                    {
                        required: true
                    }
                },
                messages:
                {
                    Title:
                    {
                        required: "Title must be entered"
                    },
                    SubTitle:
                    {
                        required: "Sub Title must be entered"
                    },
                    Description:
                    {
                        required: "Description must be entered"
                    }
                }
            });
            $("#submit_view").click(function() {
                $("#IsRedirectToView").val("true");
            });
        });
    </script>

    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
   <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    <br />
    <h2>
        Admin: Create <%= System.Configuration.ConfigurationManager.AppSettings["SiteName2"] %> News</h2>
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm("Create", "News", FormMethod.Post, new { id = "NewsForm", enctype = "multipart/form-data" }))
       {%>
    <fieldset>
        <legend>Create <%= System.Configuration.ConfigurationManager.AppSettings["SiteName2"] %> News</legend>
        <p>
            <label for="FullPath">
                Image File:</label>
            <input type="file" name="FullPath" id="FullPath" size="34" />
            <%= Html.ValidationMessage("FullPath", "*") %>
        </p>
        <p>
            <label for="Title">
                Title:</label>
            <%= Html.TextBox("Title", HttpUtility.HtmlDecode(ViewData.Model.News.Title))%>
            <%= Html.ValidationMessage("Title", "*")%>
        </p>
        <p>
            <label for="SubTitle">
                Sub Title:</label>
            <%= Html.TextBox("SubTitle", HttpUtility.HtmlDecode(ViewData.Model.News.SubTitle)) %>
            <%= Html.ValidationMessage("SubTitle", "*")%>
        </p>
        <p>
            <textarea id="Description" class="ckeditor" name="Description" rows="15" cols="80" style="width: 80%">
	        </textarea>
            <%= Html.ValidationMessage("Description", "*")%>
        </p>
        <p>
            <label for="Active">
                Active:</label>
            <%= Html.CheckBox("Active", ViewData.Model.News.Active)%>
        </p>
        <br />
        <p>
            <input type="hidden" name="type" id="type" value="LeisureLifeNews" />
            <%= Html.Hidden("IsRedirectToView")%>
           <input id="submit" name="submit" type="submit" value="Save & New" />
            <input id="submit_view" name="submit_view" type="submit" value="Save & View" />
            <input type="reset" value="Reset" />
        </p>
        <%= Html.Hidden("CommunityId", Session["CommunityId"] == null ? "" : Session["CommunityId"].ToString()) %>  
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Go back", "Index") %>
    </div>
</asp:Content>
